package com.ap.core.validation.message.rules;

import com.ap.core.cxf.jaxb.msghdr.MessageType;
import com.ap.core.message.managepayment.info.RetrieveRTPMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfo;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User: Ranjit.Singh
 * The element <BRN> should only have a value when in the previous Submit RTP message the element <MsgType> doesnot equal SUBMITRTPFORBRN
 */
public class RV0012Rule extends AbstractValidationRule<MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo>> {


    @Override
    public boolean validate(MessageValidationInfo<RetrieveRTPMessageInfo, RTPOriginalInfo> infoObject) {
        boolean pass = false;
        if(MessageType.SUBMITRTPFORBRN.equals(infoObject.getOriginalInfo().getOriginalMessageType())) {
            pass = null != infoObject.getBoundObject().getRequestInfo().getBRN();
        }else if(MessageType.SUBMITRTPFORMOB.equals(infoObject.getOriginalInfo().getOriginalMessageType())) {
            pass = null == infoObject.getBoundObject().getRequestInfo().getBRN();
        }

        return pass;
    }


}
